package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qf.dao.StudentMapper;
import com.qf.pojo.TbStudent;
import com.qf.service.StudentPlusService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * created by 赵文韬 on 2022/6/19 17:03
 * @author 赵文韬
 */
@Service
public class StudentPlusServiceImpl implements StudentPlusService {

    @Resource
    private StudentMapper studentMapper;

    @Override
    public TbStudent selectS(TbStudent student) {

        Assert.notNull(student,()->{
            throw new RuntimeException("数据为空");
        } );
        Assert.isTrue(StringUtils.isEmpty(student.getUsername()) && StringUtils.isEmpty(student.getRepassword()), ()->{
            throw new RuntimeException("用户名或密码错误");
        });
        LambdaQueryWrapper<TbStudent> studentLambdaQueryWrapper =
                Wrappers.<TbStudent>query()
                .lambda()
                .eq(TbStudent::getUsername, student.getUsername())
                .eq(TbStudent::getRepassword, student.getRepassword());
        TbStudent tbStudent = studentMapper.selectOne(studentLambdaQueryWrapper);
        return tbStudent;
    }
}
